package com.slm.mylibrary.utils;

import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.othershe.nicedialog.BaseNiceDialog;
import com.othershe.nicedialog.NiceDialog;
import com.othershe.nicedialog.ViewConvertListener;
import com.othershe.nicedialog.ViewHolder;
import com.slm.mylibrary.R;

/**
 * @ProjectName: My Application
 * @Package: com.slm.mylibrary.utils
 * @ClassName: DialogUtils
 * @Description: java类作用描述
 * @Author: 王丹丹
 * @CreateDate: 2020/6/2 20:29
 * @UpdateUser: 更新者
 * @UpdateDate: 2020/6/2 20:29
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class DialogUtils {

    private DialogUtils() {
    }


    /**
     * 普通
     *
     * @param
     * @return
     */
    public static BaseNiceDialog obtainCommonDialog(final String contentStr,
                                                    final IDialogAlertCallback dialogAlertCallback) {
        return NiceDialog.init()
                .setLayoutId(R.layout.dialog_comment_alert)
                .setConvertListener(new ViewConvertListener() {
                    @Override

                    public void convertView(ViewHolder holder, final BaseNiceDialog dialog) {
                        Button cancelBtn = holder.getView(R.id.cancel);
                        Button sureBtn = holder.getView(R.id.sure);

                        TextView content = holder.getView(R.id.content);
                        content.setText(contentStr);
                        cancelBtn.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                            }
                        });
                        sureBtn.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                                if (dialogAlertCallback != null) {
                                    dialogAlertCallback.sure();
                                }
                            }
                        });
                    }
                })
                .setOutCancel(false)
                .setAnimStyle(R.style.CenterDialogAnimation);

    }

}
